relational, equality and logical operators return 1 if the
expression is true, and 0 if the expression is false.
The relational operators are
- <
- true if the expression on the left hand side is
less than the expression on the right hand side.
- < =
- true if the expression on the left hand side is
less than or equal to the expression on the right hand side.
- >
- true if the expression on the left hand side is
greater than the expression on the right hand side.
- > =
- true if the expression on the left hand side is
greater than or equal to the expression on the right hand side.
The relational operators all have the same precedence. If the
expression on either side is complex, then comparison is done on magnitudes.
RLaB equality operators are ==
, which is the test for
equality, and !=
, which is the test for non-equality. The
equality operators have the same precedence, and are just below the
relational operators, in terms of precedence.
logical operators are &&
, which is logical and,
and ||
, which is logical or. Logical AND operation has higher
precedence than logical OR. Both logical operators are lower in
precedence than the equality operators.
The logical operators evaluate left-to-right, however
evaluation does not stop as soon as the result is known, as in C. Full
evaluation in required because the operands are not restricted to
being simple scalars quantities. Cases where the operands are matrices
requires that full operand evaluation occur.